package com.future.myapplication;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;

import java.util.ArrayList;

public class AdapterList extends RecyclerView.Adapter<AdapterList.ViewHolder> {

    private ArrayList<PhoneBean> list = new ArrayList<>();

    public AdapterList(ArrayList<PhoneBean> data) {
        this.list = data;
    }

    private TextView str;

    static class ViewHolder extends RecyclerView.ViewHolder {
        TextView str;

        public ViewHolder(View view) {
            super(view);
            str = (TextView) view.findViewById(R.id.str);
        }

    }



    @NonNull
    @Override
    public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_view, parent, false);
        ViewHolder holder = new ViewHolder(view);
        return holder;
    }

    @Override
    public void onBindViewHolder(@NonNull ViewHolder holder, int position) {
        holder.str.setText(list.get(position).toString());
    }

    @Override
    public int getItemCount() {
        return list.size();
    }
}
